package com.zelin.rm.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * ------------------------------
 * 功能：
 * 作者：WF
 * 微信：hbxfwf13590332912
 * 创建时间：2021/11/8-14:43
 * ------------------------------
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class JmsProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    //1. 使用direct（直连模式）发送消息
    @Test
    public void test01(){
        rabbitTemplate.convertAndSend("zelin","这里使用direct模式发送消息！");
    }

    //2. 使用fanout(分裂模式)发送消息
    @Test
    public void test02(){
        rabbitTemplate.convertAndSend("zl-school","","正在使用fanout方式发送消息！");
    }

    //3. 使用topic发送消息
    @Test
    public void test03(){
        rabbitTemplate.convertAndSend("fourbooks","aa.log","发送aa.log消息!");
    }

    //4. 使用topic发送消息
    @Test
    public void test04(){
        rabbitTemplate.convertAndSend("fourbooks","goods.aa","发送goods.aa消息!");
    }

    //5. 使用topic发送消息
    @Test
    public void test05(){
        rabbitTemplate.convertAndSend("fourbooks","goods.log","发送goods.log消息!");
    }
}
